package com.netvine.iias;

import lombok.Setter;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

@Component
public class SdkServiceFactoryBean implements FactoryBean<SDKservice> {
    @Setter
    private String type;

    @Autowired
    ApplicationContext applicationContext;

    @Override
    public SDKservice getObject() throws Exception {
        switch (type){
            case "hk":
                return applicationContext.getBean(HKSDKService.class);
            case "dh":
                return applicationContext.getBean(DHSDKService.class);
            case "onvif":
                return applicationContext.getBean(ONVIFService.class);
        }
        return null;
    }

    @Override
    public Class<?> getObjectType() {
        return null;
    }
}
